package com.itpan.Service.Impl;

import com.itpan.Entity.Dto.EmployeeProcedure;
import com.itpan.Entity.Employee;
import com.itpan.Entity.StatsByT;
import com.itpan.Mapper.EmployeeMapper;
import com.itpan.Service.EmployeeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;
    @Override
    public List<Employee> getAllEmployee() {
        return employeeMapper.getAllEmployees();

    }

    @Override
    public List<Employee> getAllEmployeePage(Integer page,Integer pageSize) {
        RowBounds rowBounds=new RowBounds(page,pageSize);
        List<Employee> list = employeeMapper.getAllEmployeesPage(rowBounds);
        return list;
    }

    @Override
    public void saveEmployees(List<Employee> employeeList) {
        System.out.println(employeeList.toString());
        System.out.println(employeeList.size());
        employeeMapper.insertAll(employeeList);
    }
    @Override
    public Employee getEmployeeById(String id) {
        return employeeMapper.getEmployeeById(id);
    }

    @Override
    public void saveOne(Employee employee) {
        log.info("mapper:  {}",employee.toString());
        employeeMapper.insertOne(employee);
    }

    @Override
    public void update(Employee employee) {
        employeeMapper.update(employee);
    }

    @Override
    public void deleteById(String id) {
        employeeMapper.deleteById(id);
    }

    @Override
    public Employee findByName(String Name) {
        return employeeMapper.findByName(Name);
    }

    @Override
    public List<Employee> getbymutil(Employee employee) {
        return employeeMapper.getbymutil(employee);
    }

    @Override
    public Employee getById(String id) {
        return employeeMapper.getEmployeeById(id);
    }

    @Override
    public Employee getemployeebyemail(String employeeEmail) {
        return employeeMapper.getbyemail(employeeEmail);
    }

    @Override
    public List<StatsByT> gettopofsalary() {
        return employeeMapper.gettopsalary();
    }

    @Override
    public List<StatsByT> getlevelofEmployee() {
        return employeeMapper.getlevelofEmployee();
    }

    @Override
    public  List<EmployeeProcedure> gettopsalaryoflevel(Integer level) {
        return  employeeMapper.getHighestSalaryEmployeeByLevel(level);
    }


}
